import {MapData} from "@/class/map/MapData";
import {Polygon, PolygonData} from "@/class/map/Polygon";
import {getRandomColor} from "@/utils/utils";
import {MyMapOpt} from "@/class/map/myMapOpt";

export class Feature{
    id=""
    featureId=""
    attributes=""
    parentId=""
    name=""
    geometry=""

    constructor(config) {
        for (const key in config) {
            this[key]=config[key]
        }
        this.geometry=JSON.parse(this.geometry)
    }
    getMyMap(){
        var config = {
            mapData:new MapData({
                type:MyMapOpt.MapType.Polygon,
                name:this.name,
                top:false,
                coordsys:MyMapOpt.MapCoordSys.GPS
            }),
            polygon:new Polygon({
                fillColor:getRandomColor(),
                strokeColor:getRandomColor(),
                fillOpacity:0.5,
                path:this.geometry
            })
        }

        var myMap = new PolygonData(config);
        return myMap;
    }
}